package com.snow.useviewdemo.qiniuplay;

import android.content.res.Configuration;
import android.os.Bundle;
import android.view.WindowManager;

import com.pili.pldroid.player.widget.PLVideoTextureView;
import com.snow.common.base.BaseBasesActivity;
import com.snow.useviewdemo.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author : zyt
 * e-mail : 632105276@qq.com
 * date   : 2019-06-10
 * desc   :横 全屏 播放视频
 */
public class PlayTextureViewAct extends BaseBasesActivity {

    public static final String TEST_VIDEO = "https://cdn.changguwen.com/cms/media/20181024/0dbfb433-d976-4c54-9026-272ca2967f46-1540367091203-sd.mp4";
    @BindView(R.id.play_textureView)
    PLVideoTextureView playTextureView;

    @Override
    protected void initView() {
        //设置全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //禁止屏幕休眠
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);


        playTextureView.setVideoPath(TEST_VIDEO);
        playTextureView.start();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        playTextureView.stopPlayback();
    }
    @Override
    protected void onPause() {
        super.onPause();
        playTextureView.pause();
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.act_play_texture_view;
    }
}
